cloudrive
wrapers for cloud storage API (onedrive, ...) for Node and browser.
Usage
npm install cloudrive
const { OneDrive } = require('cloudrive')
const tok = process.env.ONE_DRIVE_TOKEN
const api = new OneDrive(tok)
const dest = `test/hello.txt`
const content = 'hello world'
const res = await api.upload({ dest, content })
if (res.ok) {
console.log('ok')
} elese {
console.log(`error: ${res.status} ${res.statusText}`)
}
const tok = process.env.ONE_DRIVE_TOKEN
const api = new OneDrive(tok)
const dest = `test/hello.jpeg`
const content = fs.readFileSync('<path to your image>')
const res = await api.upload({ dest, content })
if (res.ok) {
console.log('ok')
} elese {
console.log(`error: ${res.status} ${res.statusText}`)
}
const tok = process.env.ONE_DRIVE_TOKEN
const api = new OneDrive(tok)
const res = await api.download('test/hello.txt')
if (res.ok) {
console.log('ok')
} elese {
console.log(`error: ${res.status} ${res.statusText}`)
}